約 4,285,946 件
https://w.atwiki.jp/m_shige1979/pages/1506.html
Ruby on Rails(Windows7) 概要 Windows7でのHerokuへの設定 条件 Ruby(1.9.3)、Gem(2.0.3) ※Rubyは1.9.x系でないと正常に動作しないかもしれない 手順 「Git Bash」を起動する。 herokuにログインする $ heroku login Enter your Heroku credentials. Email hogehoge@test.com Password (typing will be hidden) Authentication successful. matsumoto@WKPC-MSHIGE1979 ~ $ 指定のディレクトリに移動して、railsアプリケーションを作成 $ cd /c/pleiades_works/src/heroku $ rails new shigeharu-sample-001 create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app create app/assets/images/rails.png create app/assets/javascripts/application.js create app/assets/stylesheets/application.css create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/views/layouts/application.html.erb create app/mailers/.gitkeep create app/models/.gitkeep create config create config/routes.rb create config/application.rb create config/environment.rb create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/secret_token.rb create config/initializers/session_store.rb create config/initializers/wrap_parameters.rb create config/locales create config/locales/en.yml create config/boot.rb create config/database.yml create db create db/seeds.rb create doc create doc/README_FOR_APP create lib create lib/tasks create lib/tasks/.gitkeep create lib/assets create lib/assets/.gitkeep create log create log/.gitkeep create public create public/404.html create public/422.html create public/500.html create public/favicon.ico create public/index.html create public/robots.txt create script create script/rails create test/fixtures create test/fixtures/.gitkeep create test/functional create test/functional/.gitkeep create test/integration create test/integration/.gitkeep create test/unit create test/unit/.gitkeep create test/performance/browsing_test.rb create test/test_helper.rb create tmp/cache create tmp/cache/assets create vendor/assets/javascripts create vendor/assets/javascripts/.gitkeep create vendor/assets/stylesheets create vendor/assets/stylesheets/.gitkeep create vendor/plugins create vendor/plugins/.gitkeep run bundle install Fetching gem metadata from https //rubygems.org/........... Fetching gem metadata from https //rubygems.org/.. Resolving dependencies... Using rake (10.0.4) Using i18n (0.6.1) Using multi_json (1.7.3) Using activesupport (3.2.13) Using builder (3.0.4) Using activemodel (3.2.13) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.2) Using tilt (1.4.1) Using sprockets (2.2.2) Using actionpack (3.2.13) Using mime-types (1.23) Using polyglot (0.3.3) Using treetop (1.4.12) Using mail (2.5.4) Using actionmailer (3.2.13) Using arel (3.0.2) Using tzinfo (0.3.37) Using activerecord (3.2.13) Using activeresource (3.2.13) Using bundler (1.3.5) Using coffee-script-source (1.6.2) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.8.0) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3.2.13) Using coffee-rails (3.2.2) Using jquery-rails (2.2.1) Using rails (3.2.13) Using sass (3.2.9) Using sass-rails (3.2.6) Using sqlite3 (1.3.7) Using uglifier (2.1.1) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. $ Gitリポジトリの初期化 $ cd shigeharu-sample-001/ $ git init Initialized empty Git repository in c /pleiades_works/src/heroku/shigeharu-sample-001/.git/ matsumoto@WKPC-MSHIGE1979 /c/pleiades_works/src/heroku/shigeharu-sample-001 (master) $ ひな形の作成しマイグレーション実行 $ rails generate scaffold User name string invoke active_record create db/migrate/20130518235911_create_users.rb create app/models/user.rb invoke test_unit create test/unit/user_test.rb create test/fixtures/users.yml invoke resource_route route resources users invoke scaffold_controller create app/controllers/users_controller.rb invoke erb create app/views/users create app/views/users/index.html.erb create app/views/users/edit.html.erb create app/views/users/show.html.erb create app/views/users/new.html.erb create app/views/users/_form.html.erb invoke test_unit create test/functional/users_controller_test.rb invoke helper create app/helpers/users_helper.rb invoke test_unit create test/unit/helpers/users_helper_test.rb invoke assets invoke coffee create app/assets/javascripts/users.js.coffee invoke scss create app/assets/stylesheets/users.css.scss invoke scss create app/assets/stylesheets/scaffolds.css.scss $ rake db migrate == CreateUsers migrating ==================================================== -- create_table( users) - 0.0110s == CreateUsers migrated (0.0240s) =========================================== $ ローカル環境の実行確認 $ rails s = Booting WEBrick = Rails 3.2.13 application starting in development on http //0.0.0.0 3000 = Call with -d to detach = Ctrl-C to shutdown server [2013-05-19 09 00 11] INFO WEBrick 1.3.1 [2013-05-19 09 00 11] INFO ruby 1.9.3 (2013-05-15) [i386-mingw32] [2013-05-19 09 00 11] INFO WEBrick HTTPServer#start pid=10324 port=3000 画面 Gemfileを編集 $ vim Gemfile Gemfileの修正内容 source https //rubygems.org gem rails , 3.2.13 # Bundle edge Rails instead # gem rails , git = git //github.com/rails/rails.git # gem sqlite3 gem sqlite3 , group development gem pg , group production # Gems used only for assets and not required # in production environments by default. group assets do gem sass-rails , ~ 3.2.3 gem coffee-rails , ~ 3.2.1 # See https //github.com/sstephenson/execjs#readme for more supported runtimes # gem therubyracer , platforms = ruby gem uglifier , = 1.0.3 end gem jquery-rails # To use ActiveModel has_secure_password # gem bcrypt-ruby , ~ 3.0.0 # To use Jbuilder templates for JSON # gem jbuilder # Use unicorn as the app server # gem unicorn # Deploy with Capistrano # gem capistrano # To use debugger # gem debugger bundle installを実行 $ bundle install --without production Resolving dependencies... Using rake (10.0.4) Using i18n (0.6.1) Using multi_json (1.7.3) Using activesupport (3.2.13) Using builder (3.0.4) Using activemodel (3.2.13) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.2) Using tilt (1.4.1) Using sprockets (2.2.2) Using actionpack (3.2.13) Using mime-types (1.23) Using polyglot (0.3.3) Using treetop (1.4.12) Using mail (2.5.4) Using actionmailer (3.2.13) Using arel (3.0.2) Using tzinfo (0.3.37) Using activerecord (3.2.13) Using activeresource (3.2.13) Using bundler (1.3.5) Using coffee-script-source (1.6.2) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.8.0) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3.2.13) Using coffee-rails (3.2.2) Using jquery-rails (2.2.1) Using rails (3.2.13) Using sass (3.2.9) Using sass-rails (3.2.6) Using sqlite3 (1.3.7) Using uglifier (2.1.1) Your bundle is complete! Gems in the group production were not installed. Use `bundle show [gemname]` to see where a bundled gem is installed. $ アプリケーションを作成 $ heroku apps create Creating peaceful-harbor-4200... done, region is us http //peaceful-harbor-4200.herokuapp.com/ | git@heroku.com peaceful-harbor-4200.git Git remote heroku added $ ここで発行されたgitのパスをコピーしておく Gitでコミット $ git add . warning LF will be replaced by CRLF in .gitignore. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Gemfile. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Gemfile.lock. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in README.rdoc. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Rakefile. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/javascripts/application.js. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/javascripts/users.js.coffee. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/application.css. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/scaffolds.css.scss. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/users.css.scss. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/controllers/application_controller.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/controllers/users_controller.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/helpers/application_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/helpers/users_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/models/user.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/layouts/application.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/_form.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/edit.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/index.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/new.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/show.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config.ru. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/application.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/boot.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/database.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environment.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/development.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/production.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/backtrace_silencers.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/inflections.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/mime_types.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/secret_token.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/session_store.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/wrap_parameters.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/locales/en.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/routes.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in db/migrate/20130518235911_create_users.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in db/seeds.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in doc/README_FOR_APP. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/404.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/422.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/500.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/index.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/robots.txt. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in script/rails. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/fixtures/users.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/functional/users_controller_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/performance/browsing_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/test_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/unit/helpers/users_helper_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/unit/user_test.rb. The file will have its original line endings in your working directory. $ git commit -m "first commit" [master (root-commit) 66aba4a] first commit warning LF will be replaced by CRLF in .gitignore. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Gemfile. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Gemfile.lock. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in README.rdoc. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in Rakefile. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/javascripts/application.js. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/javascripts/users.js.coffee. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/application.css. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/scaffolds.css.scss. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/assets/stylesheets/users.css.scss. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/controllers/application_controller.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/controllers/users_controller.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/helpers/application_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/helpers/users_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/models/user.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/layouts/application.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/_form.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/edit.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/index.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/new.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in app/views/users/show.html.erb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config.ru. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/application.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/boot.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/database.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environment.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/development.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/production.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/environments/test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/backtrace_silencers.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/inflections.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/mime_types.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/secret_token.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/session_store.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/initializers/wrap_parameters.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/locales/en.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in config/routes.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in db/migrate/20130518235911_create_users.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in db/seeds.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in doc/README_FOR_APP. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/404.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/422.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/500.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/index.html. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in public/robots.txt. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in script/rails. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/fixtures/users.yml. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/functional/users_controller_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/performance/browsing_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/test_helper.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/unit/helpers/users_helper_test.rb. The file will have its original line endings in your working directory. warning LF will be replaced by CRLF in test/unit/user_test.rb. The file will have its original line endings in your working directory. 67 files changed, 1538 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/assets/images/rails.png create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/users.js.coffee create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/assets/stylesheets/users.css.scss create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/users_controller.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 app/helpers/users_helper.rb create mode 100644 app/mailers/.gitkeep create mode 100644 app/models/.gitkeep create mode 100644 app/models/user.rb create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/users/_form.html.erb create mode 100644 app/views/users/edit.html.erb create mode 100644 app/views/users/index.html.erb create mode 100644 app/views/users/new.html.erb create mode 100644 app/views/users/show.html.erb create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/secret_token.rb create mode 100644 config/initializers/session_store.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/en.yml create mode 100644 config/routes.rb create mode 100644 db/migrate/20130518235911_create_users.rb create mode 100644 db/schema.rb create mode 100644 db/seeds.rb create mode 100644 doc/README_FOR_APP create mode 100644 lib/assets/.gitkeep create mode 100644 lib/tasks/.gitkeep create mode 100644 log/.gitkeep create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/favicon.ico create mode 100644 public/index.html create mode 100644 public/robots.txt create mode 100644 script/rails create mode 100644 test/fixtures/.gitkeep create mode 100644 test/fixtures/users.yml create mode 100644 test/functional/.gitkeep create mode 100644 test/functional/users_controller_test.rb create mode 100644 test/integration/.gitkeep create mode 100644 test/performance/browsing_test.rb create mode 100644 test/test_helper.rb create mode 100644 test/unit/.gitkeep create mode 100644 test/unit/helpers/users_helper_test.rb create mode 100644 test/unit/user_test.rb create mode 100644 vendor/assets/javascripts/.gitkeep create mode 100644 vendor/assets/stylesheets/.gitkeep create mode 100644 vendor/plugins/.gitkeep $ Herokuへデプロイ $ git push heroku master Counting objects 87, done. Delta compression using up to 2 threads. Compressing objects 100% (76/76), done. Writing objects 100% (87/87), 30.39 KiB, done. Total 87 (delta 2), reused 0 (delta 0) ----- Ruby/Rails app detected ----- WARNING Removing `Gemfile.lock` because it was generated on Windows. Bundler will do a full resolve so native gems are handled properly. This may result in unexpected gem versions being used in your app. ----- Installing dependencies using Bundler version 1.3.2 Running bundle install --without development test --path vendor/bundle --binstubs vendor/bundle/bin Fetching gem metadata from https //rubygems.org/........... Fetching gem metadata from https //rubygems.org/.. Resolving dependencies... Installing rake (10.0.4) Installing i18n (0.6.1) Installing multi_json (1.7.3) Installing activesupport (3.2.13) Installing builder (3.0.4) Installing activemodel (3.2.13) Installing erubis (2.7.0) Installing journey (1.0.4) Installing rack (1.4.5) Installing rack-cache (1.2) Installing rack-test (0.6.2) Installing hike (1.2.2) Installing tilt (1.4.1) Installing sprockets (2.2.2) Installing actionpack (3.2.13) Installing mime-types (1.23) Installing polyglot (0.3.3) Installing treetop (1.4.12) Installing mail (2.5.4) Installing actionmailer (3.2.13) Installing arel (3.0.2) Installing tzinfo (0.3.37) Installing activerecord (3.2.13) Installing activeresource (3.2.13) Using bundler (1.3.2) Installing coffee-script-source (1.6.2) Installing execjs (1.4.0) Installing coffee-script (2.2.0) Installing rack-ssl (1.3.3) Installing json (1.8.0) Installing rdoc (3.12.2) Installing thor (0.18.1) Installing railties (3.2.13) Installing coffee-rails (3.2.2) Installing jquery-rails (2.2.1) Installing pg (0.15.1) Installing rails (3.2.13) Installing sass (3.2.9) Installing sass-rails (3.2.6) Installing uglifier (2.1.1) Your bundle is complete! It was installed into ./vendor/bundle Post-install message from rdoc Depending on your version of ruby, you may need to install ruby rdoc/ri data = 1.8.6 unsupported = 1.8.7 gem install rdoc-data; rdoc-data --install = 1.9.1 gem install rdoc-data; rdoc-data --install = 1.9.2 nothing to do! Yay! Cleaning up the bundler cache. ----- Writing config/database.yml to read from DATABASE_URL ----- Preparing app for Rails asset pipeline Running rake assets precompile Asset precompilation completed (24.70s) ----- Rails plugin injection Injecting rails_log_stdout Injecting rails3_serve_static_assets ----- Discovering process types Procfile declares types - (none) Default types for Ruby/Rails - console, rake, web, worker ----- Compiled slug size 9.5MB ----- Launching... done, v6 http //peaceful-harbor-4200.herokuapp.com deployed to Heroku To git@heroku.com peaceful-harbor-4200.git * [new branch] master - master $ Herokuでマイグレーション実行 $ heroku run rake db migrate Running `rake db migrate` attached to terminal... up, run.1167 DEPRECATION WARNING You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Ra ils 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initial izers/myplugin.rb. See the release notes for more on this http //weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-be en-released. (called from top (required) at /app/Rakefile 7) DEPRECATION WARNING You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Ra ils 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initial izers/myplugin.rb. See the release notes for more on this http //weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-be en-released. (called from top (required) at /app/Rakefile 7) Connecting to database specified by DATABASE_URL Migrating to CreateUsers (20130518235911) == CreateUsers migrating ==================================================== -- create_table( users) NOTICE CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id" NOTICE CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users" - 0.0399s == CreateUsers migrated (0.0400s) =========================================== $ 画面を確認 $ heroku open 作成したアプリケーション名をユニークな別の名前へ変更する $ heroku rename shigeharu-sample-001 --app peaceful-harbor-4200 Renaming peaceful-harbor-4200 to shigeharu-sample-001... done http //shigeharu-sample-001.herokuapp.com/ | git@heroku.com shigeharu-sample-001.git Git remote heroku updated $ git remote rm heroku $ git remote add heroku git@heroku.com shigeharu-sample-001.git $ 画面
https://w.atwiki.jp/rubyonrails/pages/17.html
用語解説 RubyGems Rubyのパッケージ管理システム。 gem search 実行結果 *** LOCAL GEMS *** actionmailer (2.3.4) actionpack (2.3.4) activerecord (2.3.4) activeresource (2.3.4) activesupport (2.3.4) fxri (0.3.6) fxruby (1.6.16) hpricot (0.6.164) log4r (1.0.5) ptools (1.1.6) rack (1.0.1) rails (2.3.4) rake (0.8.7, 0.8.1) ruby-opengl (0.60.0) sqlite3-ruby (1.2.5) test-unit (2.0.1) win32-api (1.2.1, 1.2.0) win32-clipboard (0.4.4) win32-dir (0.3.2) win32-eventlog (0.5.0) win32-file (0.5.5) win32-file-stat (1.3.1) win32-process (0.5.9) win32-sapi (0.1.4) win32-sound (0.4.1) windows-api (0.2.4) windows-pr (0.9.3) gem ヘルプ gem -h 実行結果 RubyGems is a sophisticated package manager for Ruby. This is a basic help message containing pointers to more information. Usage gem -h/--help gem -v/--version gem command [arguments...] [options...] Examples gem install rake gem list --local gem build package.gemspec gem help install Further help gem help commands list all gem commands gem help examples show some examples of usage gem help platforms show information about platforms gem help COMMAND show help on COMMAND (e.g. gem help install ) Further information http //rubygems.rubyforge.org gem コマンド一覧 gem help commands 実行結果 GEM commands are build Build a gem from a gemspec cert Manage RubyGems certificates and signing settings check Check installed gems cleanup Clean up old versions of installed gems in the local repository contents Display the contents of the installed gems dependency Show the dependencies of an installed gem environment Display information about the RubyGems environment fetch Download a gem and place it in the current directory generate_index Generates the index files for a gem server directory help Provide help on the gem command install Install a gem into the local repository list Display gems whose name starts with STRING lock Generate a lockdown list of gems mirror Mirror a gem repository outdated Display all gems that need updates pristine Restores installed gems to pristine condition from files located in the gem cache query Query gem information in local or remote repositories rdoc Generates RDoc for pre-installed gems search Display all gems whose name contains STRING server Documentation and gem repository HTTP server sources Manage the sources and cache file RubyGems uses to search for gems specification Display gem specification (in yaml) stale List gems along with access times uninstall Uninstall gems from the local repository unpack Unpack an installed gem to the current directory update Update the named gems (or all installed gems) in the local repository which Find the location of a library file you can require For help on a particular command, use gem help COMMAND . Commands may be abbreviated, so long as they are unambiguous. e.g. gem i rake is short for gem install rake . scaffold 「scaffold」(スキャフォゥド 「足場」という意味) scaffoldを使うと、一連の操作を行うための画面やその裏側の処理を行うプログラムを自動生成できます。 一覧表示(ページング機能付き) 単票形式のデータ表示 新規登録 編集 削除 scaffoldの利用方法 ruby script/generate scaffold -h 実行結果 Usage script/generate scaffold ModelName [field type, field type] Options --skip-timestamps Don t add timestamps to the migration file for this model --skip-migration Don t generate a migration file for this model --force-plural Forces the generation of a plural ModelName Rails Info -v, --version Show the Rails version number and quit. -h, --help Show this help message and quit. General Options -p, --pretend Run but do not make any changes. -f, --force Overwrite files that already exist. -s, --skip Skip files that already exist. -q, --quiet Suppress normal output. -t, --backtrace Debugging show backtrace on errors. -c, --svn Modify files with subversion. (Note svn must be in path) -g, --git Modify files with git. (Note git must be in path) Description Scaffolds an entire resource, from model and migration to controller and views, along with a full test suite. The resource is ready to use as a starting point for your RESTful, resource-oriented application. Pass the name of the model (in singular form), either CamelCased or under_scored, as the first argument, and an optional list of attribute pairs. Attribute pairs are column_name sql_type arguments specifying the model s attributes. Timestamps are added by default, so you don t have to specify them by hand as created_at datetime updated_at datetime . You don t have to think up every attribute up front, but it helps to sketch out a few so you can start working with the resource immediately. For example, scaffold post title string body text published boolean gives you a model with those three attributes, a controller that handles the create/show/update/destroy, forms to create and edit your posts, and an index that lists them all, as well as a map.resources posts declaration in config/routes.rb. If you want to remove all the generated files, run script/destroy scaffold ModelName . Examples `./script/generate scaffold post` `./script/generate scaffold post title string body text published boolean` `./script/generate scaffold purchase order_id integer amount decimal` rake Rubyのビルドツール(AntやMake等) rake オプション一覧 rake -h 実行結果 rake [-f rakefile] {options} targets... Options are ... -C, --classic-namespace Put Task and FileTask in the top level namespace -D, --describe [PATTERN] Describe the tasks (matching optional PATTERN), then exit. -n, --dry-run Do a dry run without executing actions. -e, --execute CODE Execute some Ruby code and exit. -p, --execute-print CODE Execute some Ruby code, print the result, then exit. -E, --execute-continue CODE Execute some Ruby code, then continue withnormal task processing. -I, --libdir LIBDIR Include LIBDIR in the search path for required modules. -P, --prereqs Display the tasks and dependencies, then exit. -q, --quiet Do not log messages to standard output. -f, --rakefile [FILE] Use FILE as the rakefile. -R, --rakelibdir RAKELIBDIR Auto-import any .rake files in RAKELIBDIR.(default is rakelib ) --rakelib -r, --require MODULE Require MODULE before executing rakefile. --rules Trace the rules resolution. -N, --no-search, --nosearch Do not search parent directories for the Rakefile. -s, --silent Like --quiet, but also suppresses the in directory announcement. -g, --system Using system wide (global) rakefiles (usually ~/.rake/*.rake ). -G, --no-system, --nosystem Use standard project Rakefile search paths, ignore system wide rakefiles. -T, --tasks [PATTERN] Display the tasks (matching optional PATTERN) with descriptions, then exit. -t, --trace Turn on invoke/execute tracing, enable full backtrace. -v, --verbose Log message to standard output. -V, --version Display the program version. -h, -H, --help Display this help message. rake タスク一覧 rake -T タスク一覧が見られます(注意:-T 小文字じゃだめ) 参考:Ruby on Railsでrakeコマンドを使って様々なタスクを実行しよう マイグレーション DBのバージョン管理システム。 具体的には次のような仕組みです。 db/migrateディレクトリ配下にdb/migrate/20080728204433_create_categories.rbのように、DBに対する変更内容が記述されたファイルを配置 このとき、各ファイル名の先頭には「20080728204433」の部分のように、タイムスタンプに基づくバージョン情報が付く マイグレーションは現在のDBのバージョン情報を保持する。これにより、db/migration内のファイルのうち、どれがDBに反映されて、どれが反映されていないかが分かる 「db migrate」というrakeタスク(「make install」のようなバッチ処理をイメージすると分かりやすい)を実行して、未反映の変更をDBに反映させることができる(=最新状態までバージョンアップ) バージョン情報を指定してrakeタスクを実行し、バージョンを任意のバージョンにバージョンアップ、バージョンダウンさせることもできる
https://w.atwiki.jp/m_shige1979/pages/1497.html
初期設定(windows7) 概要 インストール Ruby on Rails c \ gem install rails Fetching i18n-0.6.1.gem (100%) Successfully installed i18n-0.6.1 Fetching multi_json-1.7.3.gem (100%) Successfully installed multi_json-1.7.3 Fetching activesupport-3.2.13.gem (100%) Successfully installed activesupport-3.2.13 Fetching builder-3.0.4.gem (100%) Successfully installed builder-3.0.4 Fetching activemodel-3.2.13.gem (100%) Successfully installed activemodel-3.2.13 Fetching rack-1.4.5.gem (100%) Successfully installed rack-1.4.5 Fetching rack-cache-1.2.gem (100%) Successfully installed rack-cache-1.2 Fetching rack-test-0.6.2.gem (100%) Successfully installed rack-test-0.6.2 Fetching journey-1.0.4.gem (100%) Successfully installed journey-1.0.4 Fetching hike-1.2.2.gem (100%) Successfully installed hike-1.2.2 Fetching tilt-1.4.1.gem (100%) Successfully installed tilt-1.4.1 Fetching sprockets-2.2.2.gem (100%) Successfully installed sprockets-2.2.2 Fetching erubis-2.7.0.gem (100%) Successfully installed erubis-2.7.0 Fetching actionpack-3.2.13.gem (100%) Successfully installed actionpack-3.2.13 Fetching arel-3.0.2.gem (100%) Successfully installed arel-3.0.2 Fetching tzinfo-0.3.37.gem (100%) Successfully installed tzinfo-0.3.37 Fetching activerecord-3.2.13.gem (100%) Successfully installed activerecord-3.2.13 Fetching activeresource-3.2.13.gem (100%) Successfully installed activeresource-3.2.13 Fetching mime-types-1.23.gem (100%) Successfully installed mime-types-1.23 Fetching polyglot-0.3.3.gem (100%) Successfully installed polyglot-0.3.3 Fetching treetop-1.4.12.gem (100%) Successfully installed treetop-1.4.12 Fetching mail-2.5.4.gem (100%) Successfully installed mail-2.5.4 Fetching actionmailer-3.2.13.gem (100%) Successfully installed actionmailer-3.2.13 Fetching rack-ssl-1.3.3.gem (100%) Successfully installed rack-ssl-1.3.3 Fetching thor-0.18.1.gem (100%) Successfully installed thor-0.18.1 Fetching rdoc-3.12.2.gem (100%) rdoc s executable "rdoc" conflicts with C /Ruby200-x64/bin/rdoc Overwrite the executable? [yN] ERROR Error installing rails "rdoc" from rdoc conflicts with C /Ruby200-x64/bin/rdoc c \ gem install rails rdoc s executable "rdoc" conflicts with C /Ruby200-x64/bin/rdoc Overwrite the executable? [yN] y rdoc s executable "ri" conflicts with C /Ruby200-x64/bin/ri Overwrite the executable? [yN] y Depending on your version of ruby, you may need to install ruby rdoc/ri data = 1.8.6 unsupported = 1.8.7 gem install rdoc-data; rdoc-data --install = 1.9.1 gem install rdoc-data; rdoc-data --install = 1.9.2 nothing to do! Yay! Successfully installed rdoc-3.12.2 Fetching railties-3.2.13.gem (100%) Successfully installed railties-3.2.13 Fetching bundler-1.3.5.gem (100%) Successfully installed bundler-1.3.5 Fetching rails-3.2.13.gem (100%) Successfully installed rails-3.2.13 Parsing documentation for rdoc-3.12.2 Installing ri documentation for rdoc-3.12.2 Parsing documentation for railties-3.2.13 Installing ri documentation for railties-3.2.13 Parsing documentation for bundler-1.3.5 Installing ri documentation for bundler-1.3.5 Parsing documentation for rails-3.2.13 Installing ri documentation for rails-3.2.13 4 gems installed c \ DevKitのダウンロード、インストール ダウンロード http //rubyinstaller.org/downloadsより、「DEVELOPMENT KIT」のファイルをダウンロードする 任意の場所へ解凍 インストール コマンドプロンプトを開き、解凍した場所へ移動 c \ cd C \Ruby200-x64\DevKit C \Ruby200-x64\DevKit 「ruby dk.rb init」で初期化 C \Ruby200-x64\DevKit ruby dk.rb init Initialization complete! Please review and modify the auto-generated config.yml file to ensure it contains the root directories to all of the installed Rubies you want enhanced by the DevKit. C \Ruby200-x64\DevKit 「config.yaml」を編集する # This configuration file contains the absolute path locations of all # installed Rubies to be enhanced to work with the DevKit. This config # file is generated by the ruby dk.rb init step and may be modified # before running the ruby dk.rb install step. To include any installed # Rubies that were not automagically discovered, simply add a line below # the triple hyphens with the absolute path to the Ruby root directory. # # Example # # --- # - C /ruby19trunk # - C /ruby192dev # - C /Ruby200-x64 --- 「ruby dk.rb install」でインストール C \Ruby200-x64\DevKit ruby dk.rb install [INFO] Installing C /Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/defaults/operating_system.rb [INFO] Installing C /Ruby200-x64/lib/ruby/site_ruby/devkit.rb C \Ruby200-x64\DevKit gemでパッケージインストール sqlite3 サンプルアプリ作成 sqlite3のサンプル
https://w.atwiki.jp/ebi_xyz/pages/46.html
Ruby on Rails 3 + postgresql 8.1.1の環境構築 1. postgresqlと連携するために必要なpgをインストール ■ pgをインストール # gem install pg →失敗。pg_configがないと怒られた。 ■ pg_configが必要なので「postgresql-devel」をインストール # yum install postgresql-devel # which pg_config /usr/bin/pg_config 成功。 ■ 再びpgをインストール # gem install pg Building native extensions. This could take a while... Successfully installed pg-0.11.0 1 gem installed Installing ri documentation for pg-0.11.0... Installing RDoc documentation for pg-0.11.0... # gem list | grep pg pg (0.11.0) 成功。 2. サンプルアプリケーション作成 # rails new hello -d postgresql (省略) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. 成功。しかしメッセージが気になる。 3. サーバの起動 # cd hello/ # rails server /usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.9/lib/execjs/runtimes.rb 47 in `autodetect Could not find a JavaScript runtime. See https //github.com/sstephenson/execjs for a list of available runtimes. (ExecJS RuntimeUnavailable) (省略) 失敗。 ■以下を参考にGemfileを修正してbundle installを実行 http //d.hatena.ne.jp/kurusaki/20111106/1320584941 # vi Gemfile →末行に以下を追加 --- gem execjs gem therubyracer --- # bundle install (省略) Gem Installer ExtensionBuildError ERROR Failed to build gem native extension. /usr/local/bin/ruby extconf.rb creating Makefile make compiling v8_try_catch.cpp make g++ コマンドが見つかりませんでした make *** [v8_try_catch.o] エラー 127 Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9 for inspection. Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9/ext/v8/gem_make.out An error occured while installing therubyracer (0.9.9), and Bundler cannot continue. Make sure that `gem install therubyracer -v 0.9.9 ` succeeds before bundling. ■ g++をインストール # yum install gcc-c++ ■再びサーバ起動を実行 # rails server 起動した。 http //localhost 3000/ でアクセス成功 2011-11-23
https://w.atwiki.jp/soscomp/pages/178.html
$ rails bbs $ cd bbs $ mysql -u root $ create database bbs_develpment; $ruby script/generate model coment これでいくつかのファイルが作成されます。 001_create_coments.rb class CreateComents ActiveRecord Migration def self.up create_table coments do |t| t.column name, string 以下追加 t.column coment, text t.column created_at, timestamp ココまで end end def self.down drop_table coments end end t.column (カラム名) (カラムの型) でSQLのテーブルのカラムを追加します $bbs rake db migrate korede $bbs ruby script/controller user user_controller.rb class UserController ApplicationController scaffold coment end $bbs ruby script/server http //localhost 3000/user この状態ではまだModelと Controllerしか使っていませんし 見た目も掲示板ではなくアドレス帳っといった感じです。 $bbs ruby script/generate scaffold coment user 上書き before app/views/user/list.rhtml h1 Listing coments /h1 table tr % for column in Coment.content_columns % th %= column.human_name % /th % end % /tr % for coment in @coments % tr % for column in Coment.content_columns % td %=h coment.send(column.name) % /td % end % td %= link_to Show , action = show , id = coment % /td td %= link_to Edit , action = edit , id = coment % /td td %= link_to Destroy , { action = destroy , id = coment }, confirm = Are you sure? , method = post % /td /tr % end % /table %= link_to Previous page , { page = @coment_pages.current.previous } if @coment_pages.current.previous % %= link_to Next page , { page = @coment_pages.current.next } if @coment_pages.current.next % br / %= link_to New coment , action = new % after app/views/user/list.rhtml h1 Listing coments /h1 hr % for coment in @coments % h %=h coment.id % Name %=h coment.name % time %=h coment.created_at % /h %= link_to Destroy , { action = destroy , id = coment }, confirm = Are you sure? , method = post % br h %=h coment.coment % /h br hr % end % %= link_to Previous page , { page = @coment_pages.current.previous } if @coment_pages.current.previous % %= link_to Next page , { page = @coment_pages.current.next } if @coment_pages.current.next % br / %= link_to new_coment , action = new % この記事はまだ書きかけです ああ -- ああ (2009-07-13 22 10 55) 名前 コメント このページへのアクセス数 total - today - yesterday - このページのタグ一覧 RoR 背後
https://w.atwiki.jp/sawa2/pages/19.html
ruby 日本語環境 好きな文字コードでrubyのコードを実行するには。 YAML Railsなどを使っていても何かと使えるYAMLに関するメモ Vpim 携帯電話のアドレス帳などのデータであるVCFファイルを読み込むためのメモ
https://w.atwiki.jp/kenichiro/pages/36.html
Ruby on Railsの環境を構築 まず、rubygemsをyumで入れる。 yum install rubygems gemでrailsを入れる。 gem install rails rake
https://w.atwiki.jp/maimuzo/pages/39.html
のうはう色々 メール送信のうはう やりたいこと メールをiso2022jpで送信したい。 SenderID/SPFなどに対応するために各ヘッダーを変更したい。特にreturn-path 考え方と現状 基本ActionMailerをベースにする ActionMailerではメールボディの文字コード変換まではサポートされている。でもsubjectやfromに日本語が入ると化ける ActionMailerを拡張したIso2022jpMailerというライブラリがActiveHeartプラグインに付属するが、subjectを変換してなれないなど、いま一歩感が残る。 プラグインなどで「これが一般的!」というのは無い? みんなIso2022jpMailerベースで必要なところだけ文字コード変換して使ってるのかな? だとするなら、ActionMailerのdeliver*メソッドで必要部分だけNKFなどで変換すれば、別途プラグインを使う必要はないのでは? bodyの変換機能はデフォルトで付いてるし。 てかそれってDRYの原則に反してるよね。 結局何がベスト? config/environment.rbの最後に ActionMailer Base.sendmail_settings = { location = /usr/sbin/sendmail , arguments = -i -t -f from.mailaddress@example.com } ActionMailer Base.delivery_method = sendmail #ActionMailer Base.delivery_method = smtp ActionMailer Base.raise_delivery_errors = true ActionMailer Base.default_charset = iso-2022-jp を追加。sendmailの-fオプションで送信元メールアドレスとreturn-pathに使うアドレスを指定。 モデルはこんな感じ。コントローラーからdeliver_to_logined_user(object, user)で呼ぶ。 class Notifier Iso2022jpMailer def to_logined_user( object, user ) # Email header info MUST be added here recipients user.mail_address from "from.address.for.header@example.com" # 必要なところでiso2022jp変換+base64エンコードする subject "[static message]" + base64("日本語にほんご") # うまく使えないけど、ヘッダーに文字は入る # headers "¥r¥nReturn-Path" = "return-path.address.for.header@exapmle.com" # Email body substitutions go here body object_for_view = object, user_for_view = user end def base64(text, charset="iso-2022-jp", convert=true) if convert if charset == "iso-2022-jp" text = NKF.nkf( -j -m0 , text) end end text = [text].pack( m ).delete("\r\n") "=?#{charset}?B?#{text}?=" end end このbase64メソッドを標準でどこかのプラグインに入れておけば良いのかなぁ。 日本語解説ページ 優しいRailsの育て方|Action Mailer Nasuta開発ブログ|メール配信の実装 Railsアプリケーションからメール送信(Iso2022jpMailer) 日本語処理のうはう Rubyでの日本語文字列処理 デプロイのうはう masuidrive on rails|「設定より規約」でWebサーバ設定の自動化 ※増井さんのスクリプト興味あるなぁ Ajax系のうはう ここらへん読むとRailsとjson-pの絡ませ方がわかる気がする JSON-P on Rails with JQuery Cross domain RESTful JSON-P with Rails コメント 名前
https://w.atwiki.jp/maimuzo/pages/53.html
プラグイン名 BenchmarkForRailsプラグイン このプラグインができること 標準のプロファイラより細かくベンチマークを取ってくれる 標準のプロファイラが計測できないところも計測してくれる 2008/8/21現在、Rails2.1系ではエラーが出ている模様 よって実際に使ってないので注意 ちょー簡単な使い方 ruby script/plugin install http //benchmarkforrails.googlecode.com/svn/trunk mv vendor/plugins/trunk vendor/plugins/BenchmarkForRails でインストールするだけ。(?) 詳しくはvender/plugins/BenchmarkForRails/init.rbを見よう。 公式ページ BenchmarkForRails new benchmarking plugin codelevy benchmarkforrails - Google Code 日本語解説ページ ないっス 外国語解説ページ あるかもしれないけど、必要なくね? コメント 名前
https://w.atwiki.jp/dendaiman/pages/27.html
Railsメソッドへ↓ ヘルパーメソッドへ↓ Railsメソッド redirect_to order link_to has_secure_password link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 redirect_to コントローラーのアクション内で自動的にページに切り替えるためのメソッド。 order テーブルから取得してきたインスタンスを並び替えるメソッド。 e.g.)〇〇クラス.all.order("id DESC") →通常allメソッドを利用した場合にはレコードがid順に取得されるが、それを"DESC"降順に並び替えている cf.ASC(昇順) link_to Rubyタグの中で使用することができるメソッド。 HTMLのaタグとして読み込まれ、リンクとして表示される。 has_secure_password ユーザー認証機能を実装したい時に利用する。 (参考元) https //qiita.com/shumpeism/items/4d8946ade2dbdccab31c ヘルパーメソッド formヘルパー simple_format text_field whereメソッド link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 link_anchor plugin error 画像もしくは文字列を必ずどちらかを入力してください。 simple_format railsは、デフォルトの状態では改行を反映しない。このメソッドが便利。 •文字列を p で括る •改行は br / を付与 •連続した改行は、 /p p を付与 https //qiita.com/mojihige/items/c01682774e8ef29b361f formヘルパー 様々なフォームを作成する。 (参考) https //qiita.com/Hal_mai/items/1e5afd0c99dd9059839f text_field maxlengthオプション 指定した文字数を超えた入力をカットできる。 whereメソッド ActiveRecordメソッドの1種。任意のデータベースから任意の条件を指定し、テーブル内の条件に一致したレコードのインスタンスを配列型で取得できる。 (参考元) https //qiita.com/yu-croco/items/c175583cd65585e1058c ActiveRecordメソッド一覧